<template>
<!-- 头部部分 -->
  <header class="header">
      <h1>todos</h1>
      <input 
      v-model.trim="taskName" 
      @keydown.enter="addTask"
      class="new-todo" placeholder="请输入任务名称" autofocus />
    </header>
</template>

<script>
export default {
  name: 'TodoHeader',

  data() {
    return {
      taskName:''
    };
  },
  methods: {
   addTask(){
      //先进行非空判断
      if(this.taskName ==='') return
      this.$emit('addname',this.taskName)
      //清空表单
      this.taskName=''

       
    }
  },
};
</script>

<style lang="scss" scoped>

</style>